home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / pascal / pcl4p40.zip / PCL4P.REF < prev    next >
Text File  |  1993-10-17  |  62KB  |  2,401 lines

  1.  
  2.  
  3.                           Personal Communications Library
  4.  
  5.                                 For the Turbo Pascal
  6.  
  7.  
  8.                                     ( PCL4P )
  9.  
  10.  
  11.  
  12.                                REFERENCE MANUAL
  13.  
  14.  
  15.  
  16.  
  17.  
  18.                                   Version  4.0
  19.  
  20.                                   Oct 18, 1993
  21.  
  22.  
  23.  
  24.  
  25.                         This software is provided as-is.
  26.                  There are no warranties, expressed or implied.
  27.  
  28.  
  29.  
  30.  
  31.                               Copyright (C) 1993
  32.                               All rights reserved
  33.  
  34.  
  35.  
  36.                               MarshallSoft Computing, Inc.
  37.                               Post Office Box 4543
  38.                               Huntsville AL 35815
  39.  
  40.                               Voice 205-881-4630
  41.                               FAX   205-881-4630
  42.                               BBS   205-880-9748
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.         PCL4P Reference Manual                                 Page 1
  61.                                 C O N T E N T S
  62.  
  63.  
  64.  
  65.  
  66.  
  67.               Chapter                                                 Page
  68.  
  69.               Table of Contents......................................2
  70.               Introduction...........................................3
  71.                  SioBaud.............................................4
  72.                  SioBrkKey...........................................5
  73.                  SioBrkSig...........................................6
  74.                  SioCTS..............................................7
  75.                  SioDCD..............................................8
  76.                  SioDelay............................................9
  77.                  SioDone............................................10
  78.                  SioDSR.............................................11
  79.                  SioDTR.............................................12
  80.                  SioError...........................................13
  81.                  SioFIFO............................................14
  82.                  SioFlow............................................15
  83.                  SioGetc............................................16
  84.                  SioInfo............................................17
  85.                  SioIRQ.............................................18
  86.                  SioLine............................................19
  87.                  SioLoopBack........................................20
  88.                  SioModem...........................................21
  89.                  SioParms...........................................22
  90.                  SioPorts...........................................23
  91.                  SioPutc............................................24
  92.                  SioRead............................................25
  93.                  SioReset...........................................26
  94.                  SioRI..............................................27
  95.                  SioRTS.............................................28
  96.                  SioRxBuf...........................................29
  97.                  SioRxFlush.........................................30
  98.                  SioRxQue...........................................31
  99.                  SioTimer...........................................32
  100.                  SioTxBuf...........................................33
  101.                  SioTxFlush.........................................34
  102.                  SioTxQue...........................................35
  103.                  SioUART............................................36
  104.                  SioUnGetc..........................................37
  105.               Function Summary......................................38
  106.               Error Code Summary....................................39
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.         PCL4P Reference Manual                                 Page 2
  121.                              Introduction
  122.  
  123.  
  124.          This  manual  list  all the PCL4P functions in alphabetical order.
  125.          Every library function will return a value as follows:
  126.  
  127.          1.  Negative values for error conditions. See last  page  of  this
  128.          manual for a list of error values and their meanings.
  129.  
  130.          2.  Non-negative values when returning data ( eg: SioLine ).
  131.  
  132.          3.  Zero otherwise.
  133.  
  134.          When  debugging an application, be sure to test all return values.
  135.          Use SioError to print the associated text for errors.
  136.  
  137.  
  138.          Example Code Segment
  139.  
  140.          **********************************************************
  141.          *  RetCode := SioFunction();    (* any PCL4P function *) *
  142.          *  if RetCode < 0 then begin                             *
  143.          *    RetCode := SioError(RetCode);                       *
  144.          *    (* ...do some stuff... *)                           *
  145.          *    end;                                                *
  146.          **********************************************************
  147.  
  148.          For more examples, examine each of the example programs  provided.
  149.          Also  look  at  the examples associated with each library function
  150.          described in the following section.
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.         PCL4P Reference Manual                                 Page 3
  181.                                   SioBaud
  182.  
  183.  
  184.          Function    Sets the baud rate of the selected port.
  185.  
  186.            Syntax    function SioBaud(Port,BaudCode:Integer) : Integer;
  187.  
  188.           Remarks    The  SioBaud  function  sets  the  baud  rate  without
  189.                      resetting the port. It is used to change the baud rate
  190.                      after calling SioReset.
  191.  
  192.                      Baud Code           Baud Rate       PCL4P.H Name
  193.                           0                 300            Baud300
  194.                           1                 600            Baud600
  195.                           2                1200            Baud1200
  196.                           3                2400            Baud2400
  197.                           4                4800            Baud4800
  198.                           5                9600            Baud9600
  199.                           6               19200            Baud19200
  200.                           7               38400            Baud38400
  201.                           8               57600            Baud57600
  202.                           9              115200            Baud115200
  203.  
  204.  
  205.           Returns     -4 : Port out of range. Expecting   0  to 3.
  206.                      -11 : Bad baud rate code. See above code values.
  207.  
  208.           Example
  209.  
  210.                       /* do auto baud detect */
  211.                       for Code = 0 to 9 do begin
  212.                       RetCode := SioBaud(Port,Code);
  213.                       RetCode := SioPutc(Port,'A');
  214.                       if SioGetc(Port,18) = Ord('A') then
  215.                         begin
  216.                           writeln('Baud rate detected');
  217.                           (*...do something here...*)
  218.                         end
  219.                       end;
  220.  
  221.          See Also    SioReset
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.         PCL4P Reference Manual                                 Page 4
  241.                                   SioBrkKey
  242.  
  243.  
  244.          Function    Return non-zero if the Control-BREAK key was pressed.
  245.  
  246.            Syntax    function SioBrkKey : Integer;
  247.  
  248.           Remarks    The SioBrkKey function returns a TRUE value ( non zero
  249.                      ) if  the  Control-BREAK  key  was  pressed,  else  it
  250.                      returns a zero.  Use SioBrkKey as a safety exit from a
  251.                      polling   loop.   Don't  mix  this  function  up  with
  252.                      SioBrkSig.
  253.  
  254.           Returns    -1 : Control-BREAK was pressed.
  255.                       0 : Control-BREAK was NOT pressed.
  256.  
  257.           Example
  258.  
  259.                      if SioBrkKey then
  260.                        begin
  261.                          writeln('User typed Contrl-BREAK');
  262.                          RetCode := SioDone(Port);
  263.                          halt;
  264.                        end;
  265.  
  266.          See Also    SioBrkSig
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.         PCL4P Reference Manual                                 Page 5
  301.                                   SioBrkSig
  302.  
  303.  
  304.  
  305.          Function    Asserts, cancels, or detects BREAK signal.
  306.  
  307.            Syntax    function SioBrkSig(Port:Integer;Cmd:Char) : Boolean;
  308.  
  309.           Remarks    The SioBrkSig function controls the BREAK  bit
  310.                      in the line status register. The legal commands are:
  311.  
  312.                      ASSERT ('A') to assert BREAK
  313.                      CANCEL ('C') to cancel BREAK
  314.                      DETECT ('D') to detect BREAK
  315.  
  316.                      ASSERT,  CANCEL,  and  DETECT  are defined in PCL4P.H.
  317.                      See TERM.C for an example of the use of SioBrkSig.
  318.  
  319.           Returns    -2 : Port not enabled. Call SioReset first.
  320.                      -4 : Port out of range. Expecting  0 to 3.
  321.                      -6 : Illegal command. Expected 'A', 'C', or 'D'.
  322.                      >0 : BREAK signal detected ( DETECT command only )
  323.  
  324.           Example
  325.  
  326.                      (* Assert BREAK for 1 second *)
  327.                      RetCode := SioBrkSig(Port,ASSERT);
  328.                      RetCode := SioDelay(18);
  329.                      RetCode := SioBrkSig(Port,CANCEL);
  330.                      (* Detect BREAK *)
  331.                      if SioBrkSig(Port,DETECT) then
  332.                        begin
  333.                          writeln('BREAK signal detected');
  334.                            (* ...do some more stuff... *)
  335.                        end
  336.  
  337.          See Also    SioBrkKey
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.         PCL4P Reference Manual                                 Page 6
  361.                                   SioCTS
  362.  
  363.  
  364.  
  365.          Function    Reads the Clear to Send ( CTS ) modem status bit.
  366.  
  367.            Syntax    function SioCTS(Port:Integer) : Integer;
  368.  
  369.           Remarks    The  SioCTS function is used to read the Clear to Send (
  370.                      CTS ) modem status bit.
  371.  
  372.           Returns    -2 : Port not enabled. Call SioReset first.
  373.                      -4 : Port out of range.  Expecting  0 to 3.
  374.                       0 : CTS is clear.
  375.                      >0 : CTS is set.
  376.  
  377.           Example
  378.                      (* read CTS line *)
  379.                      RetCode := SioCTS(Port);
  380.                      if RetCode > 0 then write('CTS is set');
  381.                      else write('CTS is clear');
  382.  
  383.          See Also    SioDSR, SioRI, SioDCD, and SioModem.
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.         PCL4P Reference Manual                                 Page 7
  421.                                   SioDCD
  422.  
  423.  
  424.  
  425.          Function    Reads  the  Data  Carrier Detect ( DCD ) modem status
  426.                      bit.
  427.  
  428.            Syntax    function SioDCD(Port:Integer) : Integer;
  429.  
  430.           Remarks    The SioDCD function is used to read the  Data  Carrier
  431.                      Detect ( DCD ) modem status bit. Also see SioModem.
  432.  
  433.           Returns    -2 : Port not enabled. Call SioReset first.
  434.                      -4 : Port out of range.  Expecting  0 to 3.
  435.                       0 : DCD is clear.
  436.                      >0 : DCD is set.
  437.  
  438.           Example
  439.                      (* read DCD line *)
  440.                      RetCode := SioDCD(Port);
  441.                      if RetCode > 0 then write('DCD is set');
  442.                      else write('DCD is clear');
  443.  
  444.          See Also    SioDSR, SioCTS, SioRI, and SioModem.
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.         PCL4P Reference Manual                                 Page 8
  481.                                   SioDelay
  482.  
  483.  
  484.  
  485.          Function    Delays one or more tics.
  486.  
  487.            Syntax    function SioDelay(Tics:Integer) : Integer;
  488.  
  489.           Remarks    The  SioDelay  function  is used to delay one  or more
  490.                      timer tics, where each timer tic is  approximately  55
  491.                      milliseconds ( 18 to the second ).
  492.  
  493.           Returns    zero
  494.  
  495.           Example    (* delay 5 seconds *)
  496.                      RetCode := SioDelay(5*18);
  497.  
  498.          See Also    SioTimer
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.         PCL4P Reference Manual                                 Page 9
  541.                                   SioDone
  542.  
  543.  
  544.  
  545.          Function    Terminates further serial processing.
  546.  
  547.            Syntax    function SioDone(Port:Integer) : Integer
  548.  
  549.           Remarks    The  SioDone  function  terminates  further  serial
  550.                      processing. SioDone MUST be called before exiting your
  551.                      application so that  interrupts  can  be  restored  to
  552.                      their original state. Failure to do this can crash the
  553.                      operating  system.   If  you  forget  to  call SioDone
  554.                      before exiting, be sure to re-boot your computer.  You
  555.                      can call SioDone even if SioReset has not been called,
  556.                      so it is good practice to always call  SioDone  before
  557.                      exiting your application.
  558.  
  559.           Returns    -2 : Port not enabled. Call SioReset first.
  560.                      -4 : Port out of range. Expecting  0 to 3.
  561.  
  562.           Example    (* terminate processing for COM3 *)
  563.                      RetCode := SioDone(COM3);
  564.  
  565.          See Also    SioReset.
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.         PCL4P Reference Manual                                 Page 10
  601.                                   SioDSR
  602.  
  603.  
  604.  
  605.          Function    Reads the Data Set Ready ( DSR ) modem status bit.
  606.  
  607.            Syntax    function SioDSR(Port:Integer) : Integer;
  608.  
  609.           Remarks    The SioDSR function is used  to  read  the  Data  Set
  610.                      Ready ( DSR ) modem status bit.
  611.  
  612.           Returns    -2 : Port not enabled. Call SioReset first.
  613.                      -4 : Port out of range.  Expecting  0 to 3.
  614.                       0 : DSR is clear.
  615.                      >0 : DSR is set
  616.  
  617.           Example
  618.                      (* read DSR line *)
  619.                      RetCode := SioDSR(Port);
  620.                      if RetCode > 0 then write('DSR is set');
  621.                      else write('DSR is clear');
  622.  
  623.          See Also    SioCTS, SioRI, SioDCD, and SioModem
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.         PCL4P Reference Manual                                 Page 11
  661.                                   SioDTR
  662.  
  663.  
  664.  
  665.          Function    Set, clear, or read the Data Terminal Ready  (  DTR  )
  666.                      bit.
  667.  
  668.            Syntax    function SioDTR(Port,Cmd:Integer) : Integer;
  669.  
  670.           Remarks    The SioDTR function controls the Data Terminal Ready (
  671.                      DTR  )  bit in the modem control register.  Commands (
  672.                      defined in PCL4P.H ) are:
  673.  
  674.                      SetPort  ('S')  to set DTR ( ON )
  675.                      ClrPort  ('C')  to clear DTR ( OFF )
  676.                      ReadPort ('R')  to read DTR
  677.  
  678.           Returns    -2 : Port not enabled. Call SioReset first.
  679.                      -4 : Port out of range. Expecting  0 to 3.
  680.                      -5 : Not one of 'S', 'C', or 'R'.
  681.                       0 : DTR is OFF (READ Command).
  682.                      >0 : DTR is ON (READ Command).
  683.  
  684.           Example
  685.  
  686.                      (* turn DTR on for modem connected to COM4 *)
  687.                      RetCode := SioDTR(COM4,SetPort);
  688.  
  689.          See Also    SioRTS.
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.         PCL4P Reference Manual                                 Page 12
  721.                                   SioError
  722.  
  723.  
  724.          Function    Displays error in text.
  725.  
  726.            Syntax    function SioError(Code:Integer) : Integer;
  727.  
  728.           Remarks    The SioError  function  displays  the  error  in  text
  729.                      corresponding  to  the error code.  During development
  730.                      of a communications application, it is a good idea  to
  731.                      always   test   return  codes,  and  print  out  their
  732.                      descriptions with SioError.
  733.  
  734.           Returns    zero
  735.  
  736.           Example
  737.                      (* display error text if error on Reset *)
  738.                      RetCode := SioReset(Port,Baud4800);
  739.                      if RetCode < 0 then RetCode := SioError(RetCode);
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.         PCL4P Reference Manual                                 Page 13
  781.                                   SioFIFO
  782.  
  783.  
  784.  
  785.          Function    Sets the FIFO trigger level ( INS16550 only ).
  786.  
  787.            Syntax    Function SioFIFO(Port,LevelCode:Integer) : Integer
  788.  
  789.           Remarks    The SioFIFO function is used to set the trigger level
  790.                      at which interrupts are generated. For example, if the
  791.                      FIFO level is set to 8, then the  INS16550  UART  will
  792.                      not  generate  an  interrupt  until  8 bytes have been
  793.                      received.   This  reduces  the  number  of  interrupts
  794.                      generated  and  allows  faster  processing with slower
  795.                      machines or when running simultaneous  ports.
  796.  
  797.                      In  order  to  test  if  your port is a INS16550, call
  798.                      SioFIFO with a LevelCode of other than FIFO_OFF.
  799.  
  800.                      SioFIFO  can  be  called  for  the INS8250 without ill
  801.                      effect.
  802.  
  803.  
  804.                      Code  PCL4C.H Name  Trigger Level
  805.                      -1      FIFO_OFF     Disable FIFO
  806.                       0      LEVEL_1      1 byte
  807.                       1      LEVEL_4      4 bytes
  808.                       2      LEVEL_8      8 bytes
  809.                       3      LEVEL_14     14 bytes
  810.  
  811.  
  812.           Returns    -2 : Port not enabled. Call SioReset first.
  813.                      -4 : Port out of range.  Expecting  0 to 3.
  814.                      >0 : FIFO level set.
  815.                       0 : FIFO level not set ( not INS16550 ).
  816.  
  817.           Example    (* Set FIFO level to 8 *)
  818.                      if SioFIFO(Port,LEVEL_8) then writeln('FIFO reset')
  819.                      else writeln('UART in not INS16550');
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.         PCL4P Reference Manual                                 Page 14
  841.                                   SioFlow
  842.  
  843.  
  844.  
  845.          Function    Sets hardware (RTS/CTS) flow contol.
  846.  
  847.            Syntax    Function SioFIFO(Port,Tics:Integer) : Integer
  848.  
  849.           Remarks    The  SioFlow  function  is  used  to enable or disable
  850.                      hardware fow control. Hardware flow control  uses  RTS
  851.                      and CTS to control data flow between the modem and the
  852.                      computer.  Refer to the User's Manual for a discussion
  853.                      of flow control. To enable hardware flow control, call
  854.                      SioFlow with Tics > 0.
  855.  
  856.                      "Tics" is the number of timer  tics  (18  per  second)
  857.                      before a call to SioPutc will time out because because
  858.                      the modem dropped CTS.
  859.  
  860.                      In order for hardware flow control to work  correctly,
  861.                      your  modem  must  also  be  configured  to  work with
  862.                      hardware flow control,  and  your  computer  to  modem
  863.                      cable must have RTS and CTS wired staright through. if
  864.                      you  enable  hardware  flow control, do not modify the
  865.                      RTS line (by calling SioRTS) unless you  know  exactly
  866.                      what you are doing.
  867.  
  868.                      Flow  control  is  disabled after resetting a port. To
  869.                      explicitly disable hardware flow contol, call  SioFlow
  870.                      with Tics = -1.
  871.  
  872.           Returns    -2 : Port not enabled. Call SioReset first.
  873.                      -4 : Port out of range.  Expecting  0 to 3.
  874.                      =0 : Flow control disabled.
  875.                      >0 : Flow control enabled.
  876.  
  877.           Example    (* Enable flow control on COM1 *)
  878.                      Code := SioFlow(COM1,18);
  879.                      if Code > 0 then WriteLn('Flow control enabled')
  880.                      else Code := SioError(Code);
  881.  
  882.                      (* Disable flow control on COM2 *)
  883.                      Code := SioFlow(COM2,-1);
  884.                      if Code = 0 then WriteLn('Flow control disabled')
  885.                      else Code := SioError(Code);
  886.  
  887.          Also See    SioPutc
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.         PCL4P Reference Manual                                 Page 15
  901.                                   SioGetc
  902.  
  903.  
  904.          Function    Reads the next character from the serial line.
  905.  
  906.            Syntax    function SioGetc(Port,Tics:Integer) : Integer;
  907.  
  908.           Remarks    The  SioGetc function reads the selected serial port.
  909.                      The function will wait for the number of  system  tics
  910.                      given  by  the 'Tics' argument before returning 'timed
  911.                      out'. There are 18 tics to the second.
  912.  
  913.                      To specify no waiting, call SioGetc with Tics = 0.
  914.  
  915.           Returns    -2 : Port not enabled. Call SioReset first.
  916.                      -4 : Port out of range. Expecting  0 to 3.
  917.                      -1 : If timed out.
  918.                      >0 : Character read.
  919.  
  920.           Example
  921.                      (* get next character from COM1 *)
  922.                      RetCode := SioGetc(COM1,1);
  923.                      if RetCode <> -1
  924.                        then  writeln('Character is ', chr(RetCode) );
  925.                        else writeln('Timed out');
  926.  
  927.          See Also    SioUnGetc and SioPutc.
  928.  
  929.  
  930.  
  931.  
  932.  
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.         PCL4P Reference Manual                                 Page 16
  961.                                   SioInfo
  962.  
  963.  
  964.          Function    Returns PCL4P library version number.
  965.  
  966.            Syntax    function SioInfo(Cmd : Char) : Integer;
  967.  
  968.           Remarks    The  SioInfo  function  returns  an   integer   code
  969.                      corresponding to the library version number.
  970.  
  971.  
  972.           Returns
  973.                      Version ('V')
  974.  
  975.                      hex byte XY where version is denoted as X.Y
  976.  
  977.                      TX Interrupts ('I')
  978.  
  979.                      0  if  transmitter  interrupts  are  disabled  in  the
  980.                      library, otherwise returns other than 0.
  981.  
  982.           Example    (* return version number *)
  983.                      Version := SioInfo('V');
  984.                      WriteLn('Version ',Version div 16,Version mod 16);
  985.                      Write('TX Interrupts are ');
  986.                      if SioInfo('I') then WriteLn('enabled');
  987.                      else WriteLn('disabled');
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.         PCL4P Reference Manual                                 Page 17
  1021.                                   SioIRQ
  1022.  
  1023.  
  1024.  
  1025.          Function    Assigns an IRQ line to a port.
  1026.  
  1027.            Syntax    function SioIRQ(Port,IRQcode):Integer;
  1028.  
  1029.           Remarks    The  SioIRQ  function assigns an IRQ line to a port.
  1030.                      SioIRQ (like SioUART) must be  called  before  calling
  1031.                      SioReset in order to have any effect.  Unless you have
  1032.                      a  non-standard  serial  port  configuration, you will
  1033.                      never need to call SioIRQ.
  1034.  
  1035.                      In particular, remember that your port  hardware  must
  1036.                      generate  the  interrupt that you have specified. Also
  1037.                      be carefull about conflicting interrupt assignments.
  1038.  
  1039.                      Be  sure  to  call  SioPorts  first to setup DigiBoard
  1040.                      ports if you have  them.  Refer  to  the  PCL4P  Users
  1041.                      Manual for additional information.
  1042.  
  1043.           Returns    -4 : Port out of range. Expecting 0 to 3.
  1044.                      -15 : Port already enabled. SioReset already called.
  1045.                      -17 : No such IRQ. ( should be 0 to 7).
  1046.                      -18 : No such ISR. (should be 0 to 4).
  1047.                        0 : Otherwise
  1048.  
  1049.           Example    (* use IRQ5 for COM3 -- non-DigiBoard port*)
  1050.                      rc := SioUART(COM3,0x3220);
  1051.                      rc := SioIRQ(COM3,IRQ5);
  1052.                      (* we can now run 3 ports concurrently *)
  1053.                      ...
  1054.  
  1055.          See Also    SioUART and SioPorts.
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.         PCL4P Reference Manual                                 Page 18
  1081.                                   SioLine
  1082.  
  1083.  
  1084.  
  1085.          Function    Reads the line status register.
  1086.  
  1087.            Syntax    function SioLine(Port:Integer) : Integer;
  1088.  
  1089.           Remarks    The  SioLine function reads the line status register.
  1090.                      The individual bit masks are as follows:
  1091.  
  1092.                      0x40  = Transmitter empty.
  1093.                      0x20  = Transmitter buffer empty.
  1094.                      0x10  = Break detected.
  1095.                      0x08  = Framming error.
  1096.                      0x04  = Parity error.
  1097.                      0x02  = Overrun error.
  1098.                      0x01  = Data ready.
  1099.  
  1100.                      The above are documented in the file PCL4P.H.
  1101.  
  1102.           Returns    -2 : Port not enabled. Call SioReset first.
  1103.                      -4 : Port out of range. Expecting  0 to 3.
  1104.                      >0 : Line status ( rightmost byte of word ).
  1105.  
  1106.           Example
  1107.                      (* decode line register *)
  1108.                      RetCode := SioLine(Port);
  1109.                      if(RetCode and
  1110.                        (FramingError or ParityError or OverrunError)) <> 0
  1111.                        then begin
  1112.                          if (RetCode and FramingError) <> 0
  1113.                                  then writeln('Framing Error');
  1114.                          if (RetCode and ParityError) <> 0
  1115.                                  then writeln('Parity Error');
  1116.                          if (RetCode and OverrunError) <> 0
  1117.                                  then writeln('Overrun Error')
  1118.                        end
  1119.                      else writeln('No error');
  1120.  
  1121.          See Also    SioModem & SioRead.
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.         PCL4P Reference Manual                                 Page 19
  1141.                                    SioLoopBack
  1142.  
  1143.  
  1144.  
  1145.          Function    Does a UART loopback test.
  1146.  
  1147.            Syntax    function SioLoopBack(Port:Integer) : Integer;
  1148.  
  1149.           Remarks    SioLoopBack  makes  use of the built in loopback test
  1150.                      capability of the INS8250 UART.  Normally  SioLoopBack
  1151.                      will  never  need  to  be called except if you suspect
  1152.                      that your UART is bad. See the LOOPBACK.C program.
  1153.  
  1154.  
  1155.           Returns      0 : Loopback test is successfull.
  1156.                       -2 : Port not enabled. Call SioReset first.
  1157.                       -4 : Port out of range.  Expecting   0  to 3.
  1158.                      -12 : Loopback test fails.
  1159.  
  1160.  
  1161.           Example
  1162.                      (* perform loopback test *)
  1163.                      RetCode := SioLoopBack(Port);
  1164.                      if RetCode = 0
  1165.                        then write('Loopback test has succeeded');
  1166.                        else write('Loopback test has failed');
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200.         PCL4P Reference Manual                                 Page 20
  1201.                                   SioModem
  1202.  
  1203.  
  1204.  
  1205.          Function    Reads the modem status register.
  1206.  
  1207.            Syntax    function SioModem(Port:Integer; Mask:Char) ; Integer;
  1208.  
  1209.           Remarks    The  SioModem function reads the modem register.  The
  1210.                      bit definitions for the function mask are as follows:
  1211.  
  1212.                      Bit  Name     Function
  1213.                       7   DCD       Data Carrier Detect
  1214.                       6   RI        Ring Indicator
  1215.                       5   DSR       Data Set Ready
  1216.                       4   CTS       Clear To Send
  1217.                       3   DeltaDCD  Delta DCD ( DCD has changed )
  1218.                       2   DeltaRI   Delta RI ( RI has changed )
  1219.                       1   DeltaDSR  Delta DSR ( DSR has changed )
  1220.                       0   DeltaCTS  Delta CTS ( CTS has changed )
  1221.  
  1222.                      Bits 4 through 7 represent the absolute state of their
  1223.                      respective RS-232 inputs.  Bits 0 through 3 repesent a
  1224.                      change in the state of their respective RS-232  inputs
  1225.                      since last read.
  1226.  
  1227.                      The above definitions are also in the PCL4P.H file for
  1228.                      use by your application program.
  1229.  
  1230.           Returns    -2 : Port not enabled. Call SioReset first.
  1231.                      -4 : Port out of range. Expecting  0 to 3.
  1232.                      >0 : Modem status ( rightmost byte of word ).
  1233.  
  1234.           Example
  1235.  
  1236.                      (* any change in DCD ? *)
  1237.                      Status := SioModem(Port,DeltaDCD);
  1238.                      if Status < 0 then
  1239.                        begin
  1240.                          RetCode := SioError(Status);
  1241.                          Halt;
  1242.                        end;
  1243.                      else writeln('DCD status = ', SioModem(Port,DCD) );
  1244.  
  1245.          See Also    SioCTS, SioDCD, SioDSR and SioRI.
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.         PCL4P Reference Manual                                 Page 21
  1261.                                   SioParms
  1262.  
  1263.  
  1264.  
  1265.          Function    Sets parity, stop bits, and word length.
  1266.  
  1267.            Syntax    function SioParms(Port,ParityCode,StopBitsCode,
  1268.                          WordLengthCode:Integer) : Integer;
  1269.  
  1270.  
  1271.           Remarks    The SioParms function sets the parity, stop bits, and
  1272.                      word length.  If the default parity  (  none  ),  stop
  1273.                      bits  (  1  ), or word length ( 8 ) is not acceptable,
  1274.                      then they can be changed by calling SioParms. SioParms
  1275.                      can be called either before or after calling SioReset.
  1276.                      See file PCL4P.H.
  1277.  
  1278.                                     Value   Description    PCL4P.H Name
  1279.                      ParityCode:    *0      no parity      NoParity
  1280.                                      1      odd parity     OddParity
  1281.                                      3      even parity    EvenParity
  1282.  
  1283.                      StopBitsCode:  *0      1 stop bit     OneStopBit
  1284.                                      1      2 stop bits    TwoStopBits
  1285.  
  1286.                      WordLengthCode: 0      5 data bits    WordLength5
  1287.                                      1      6 data bits    WordLength6
  1288.                                      2      7 data bits    WordLength7
  1289.                                     *3      8 data bits    WordLength8
  1290.  
  1291.                      * = Default
  1292.  
  1293.           Returns    -4 : Port out of range. Expecting 0 to 3.
  1294.                      -7 : Bad parity code selected. Expecting  0 to 2.
  1295.                      -8 : Bad stop bits code. Expecting  0 or 1.
  1296.                      -9 : Bad word length code. Expecting  0 to 3.
  1297.  
  1298.           Example
  1299.                      (* set serial parameters *)
  1300.                      RetCode := SioParms(COM1,NoParity,OneStopBit,WordLength8);
  1301.  
  1302.          See Also    SioReset.
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.         PCL4P Reference Manual                                 Page 22
  1321.                                   SioPorts
  1322.  
  1323.  
  1324.  
  1325.          Function    To  set  the  number of ports, the 1st DigiBoard port
  1326.                      and the DigiBoard status register address.
  1327.  
  1328.            Syntax    function SioPorts(NumberPorts,FirstPort,StatusReg :
  1329.                         Integer) : Integer;
  1330.  
  1331.           Remarks    The  SioPorts function must be called before ANY other
  1332.                      serial functions. The purpose of the SioPorts function
  1333.                      is to  set  the  total  number  of  ports,  the  first
  1334.                      DigiBoard  port  and  the  DigiBoard  status  register
  1335.                      address.
  1336.  
  1337.                      Once  SioPorts  is called, all COM ports starting with
  1338.                      "FirstPort" will be treated as  DigiBoard  ports.  The
  1339.                      default  setup is 4 standard PC ports and no DigiBoard
  1340.                      ports [ SioPorts(4,4,0); ].
  1341.  
  1342.                      The  standard  DigiBoard  status register is 0x140. If
  1343.                      you  change  this  address  on your DigiBoard, be sure
  1344.                      to specify the correct value for "StatusReg".
  1345.  
  1346.           Returns   -4 : No such port. Expect 0 to 11.
  1347.                      0 : No error (sets MaxPort to NumberPorts-1).
  1348.  
  1349.           Example    /* Want 2 PC ports & 8 DigiBoard ports (on PC/8) */
  1350.                      Code := SioPorts(10,COM3,$140);
  1351.  
  1352.                      /* Want 1 PC port & 4 DigiBoard ports (on PC/4) */
  1353.                      Code := SioPorts(5,COM2,$140);
  1354.  
  1355.          See Also    SioUART, SioIRQ.
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.         PCL4P Reference Manual                                 Page 23
  1381.                                   SioPutc
  1382.  
  1383.  
  1384.  
  1385.          Function    Transmit a character over a serial line.
  1386.  
  1387.            Syntax    function SioPutc(Port:Integer; Ch:Char) : Integer;
  1388.  
  1389.           Remarks    The SioPutc function transmits one character over the
  1390.                      selected serial line.
  1391.  
  1392.                      If flow control has been  enabled,  then  SioPutc  may
  1393.                      return a -1 (time out) if the number of tics specified
  1394.                      in  the  SioFlow function was exceeded waiting for the
  1395.                      modem to raise CTS. Refer to the User's Manual  for  a
  1396.                      discussion of flow control.
  1397.  
  1398.           Returns    -2 : Port not enabled. Call SioReset first.
  1399.                      -4 : Port out of range. Expecting  0 to 3.
  1400.                      -1 : Timed out waiting for CTS (flow control enabled)
  1401.           Example
  1402.                      (* compute & output the CRC *)
  1403.                      crc := 0;
  1404.                      for i = 0 to 127 do
  1405.                        begin
  1406.                          crc := crcupdate( buffer[i], crc);
  1407.                          RetCode := SioPutc(Port, buffer[i]);
  1408.                        end;
  1409.                      RetCode := SioPutc(crc);
  1410.  
  1411.          See Also    SioGetc and SioFlow.
  1412.  
  1413.  
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.         PCL4P Reference Manual                                 Page 24
  1441.                                   SioRead
  1442.  
  1443.  
  1444.  
  1445.          Function    Reads any UART register.
  1446.  
  1447.            Syntax    function SioRead(Port,Reg:Integer) : Integer;
  1448.  
  1449.           Remarks    The  SioReset  function directly reads the contents of
  1450.                      any of the 7 UART registers. This function  is  useful
  1451.                      when  debugging  application programs, and as a method
  1452.                      for verifying UART contents.
  1453.  
  1454.                      The line status register (register 5) can also be read
  1455.                      with SioLine while the modem status register (register
  1456.                      6) can also be read with SioModem.
  1457.  
  1458.                      Refer  to  the PCL4P User's Manual for a discussion of
  1459.                      the UART registers.
  1460.  
  1461.          Returns      -3 : No buffer available. Call SioRxBuf first.
  1462.                       -4 : Port out of range. Expecting  0 to 3.
  1463.  
  1464.           Example    Reg : Integer;  (* UART register *)
  1465.                      Contents : Integer; (* Contents of UART *)
  1466.                      (* print contents of 7 UART registers *)
  1467.                      for Reg=0 to 7 do
  1468.                         begin
  1469.                           Contents = SioRead(Port,Reg);
  1470.                           WriteLn('COM',1+Port,
  1471.                                   '   UART Register ',Reg,
  1472.                                   '  = ',Contents);
  1473.                         end;
  1474.  
  1475.  
  1476.  
  1477.  
  1478.  
  1479.  
  1480.  
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.         PCL4P Reference Manual                                 Page 25
  1501.                                   SioReset
  1502.  
  1503.  
  1504.  
  1505.          Function    Initialize a serial port for processing.
  1506.  
  1507.            Syntax    function SioReset(Port,BaudCode:Integer) : Integer;
  1508.  
  1509.           Remarks    The SioReset function initializes the selected serial
  1510.                      port.  SioReset should be called after calling SioParm
  1511.                      and SioRxBuf but before  making  any  other  calls  to
  1512.                      PCL4P.   SioReset uses the parity, stop bits, and word
  1513.                      length value previously set  if  SioParm  was  called,
  1514.                      otherwise the default values ( see SioParm ) are used.
  1515.  
  1516.                      Recall  that  COM1  and  COM3 share the same interrupt
  1517.                      vector and therefore  cannot  operate  simultaneously.
  1518.                      Similiarly,    COM2    and    COM4    cannot   operate
  1519.                      simultaneously. Any other combination of two ports can
  1520.                      be used.
  1521.  
  1522.                      By specifing NORESET ( -1 ) for the  baud  rate  code,
  1523.                      the  port  will  NOT  be reset.  This is used to "take
  1524.                      over" a port from a host communications  program  that
  1525.                      allows  a  "DOS  gateway".   External protocols can be
  1526.                      implemented this way. See SioBaud for a  list  of  the
  1527.                      baud rate codes, or see "PCL4P.H".
  1528.  
  1529.          Returns      -3 : No buffer available. Call SioRxBuf first.
  1530.                       -4 : Port out of range. Expecting  0 to 3.
  1531.                      -11 : Bad baud rate code selected. Expecting  0 to 9.
  1532.                      -13 : UART  undefined.   SioUART(Port,0)  was  called
  1533.                            previously.
  1534.                      -14 : Bad or missing UART.  You may not have hardware
  1535.                            present.
  1536.                      -15 : Port already enabled.  SioReset has already been
  1537.                            called.
  1538.                      -16 : Cannot enable both COM1 & COM3  or  COM2 & COM4.
  1539.  
  1540.           Example
  1541.  
  1542.                      RetCode := SioRxBuf(COM1,Ofs(Buffer),Seg(Buffer),Size128);
  1543.                      RetCode := SioReset(Com1,Baud38400);
  1544.                      if RetCode = 0 then writeln('RESET ok');
  1545.                      else begin
  1546.                        RetCode := SioError(rc);
  1547.                        if (RetCode and OverrunError) <> 0
  1548.                                          then writeln('Overrun Error');
  1549.                        if (RetCode and ParityError) <> 0
  1550.                                          then writeln('Parity Error');
  1551.                        if (RetCode and FramingError) <> 0
  1552.                                          then writeln('Framing Error');
  1553.                        if (RetCode and BreakDetected) <> 0
  1554.                                          then writeln('Break Detected');
  1555.                      end;
  1556.  
  1557.          See Also    SioBaud, SioParms, SioRxBuf, SioDone, and SioUART.
  1558.  
  1559.  
  1560.         PCL4P Reference Manual                                 Page 26
  1561.                                    SioRI
  1562.  
  1563.  
  1564.  
  1565.          Function    Reads the Ring Indicator ( RI ) modem status bit.
  1566.  
  1567.            Syntax    function SioRI(Port:Integer) : Integer;
  1568.  
  1569.           Remarks    The SioRI function is used to read the Ring Indicator
  1570.                      ( RI ) modem status bit. Also see SioModem.
  1571.  
  1572.           Returns    -2 : Port not enabled. Call SioReset first.
  1573.                      -4 : Port out of range.  Expecting   0  to 3.
  1574.                       0 : RI is clear.
  1575.                      >0 : RI is set ( RING has occurred ).
  1576.  
  1577.           Example
  1578.                      (* read the RI line *)
  1579.                      RetCode := SioRI(Port);
  1580.                      if RetCode > 0 then write('RING');
  1581.  
  1582.          See Also    SioDSR, SioCTS, SioDCD, and SioModem.
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593.  
  1594.  
  1595.  
  1596.  
  1597.  
  1598.  
  1599.  
  1600.  
  1601.  
  1602.  
  1603.  
  1604.  
  1605.  
  1606.  
  1607.  
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.         PCL4P Reference Manual                                 Page 27
  1621.                                   SioRTS
  1622.  
  1623.  
  1624.  
  1625.          Function    Sets,  clears,  or  reads the Request to Send ( RTS )
  1626.                      line.
  1627.  
  1628.            Syntax    function SioRTS(Port:Integer; Cmd:Char) : Integer;
  1629.  
  1630.           Remarks    The SioRTS function controls the  Request  to  Send  (
  1631.                      RTS  )  bit  in the modem control register. Commands (
  1632.                      defined in PCL4P.H ) are:
  1633.  
  1634.                      SetPort  ('S')   -- set RTS ( ON )
  1635.                      ClrPort  ('C') -- clear RTS ( OFF )
  1636.                      ReadPort ('R')  -- read RTS
  1637.  
  1638.           Returns    -2 : Port not enabled. Call SioReset first.
  1639.                      -4 : Port out of range. Expecting  0 to 3.
  1640.                      -5 : Command is not one of 'S', 'C', or 'R'.
  1641.                       0 : RTS is OFF (READ Command).
  1642.                      >0 : RTS is ON  (READ Command).
  1643.  
  1644.           Example
  1645.  
  1646.                      (* turn off RTS for modem *)
  1647.                      RetCode := SioRTS(Port,ClrPort);
  1648.  
  1649.          See Also    SioDTR.
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655.  
  1656.  
  1657.  
  1658.  
  1659.  
  1660.  
  1661.  
  1662.  
  1663.  
  1664.  
  1665.  
  1666.  
  1667.  
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.         PCL4P Reference Manual                                 Page 28
  1681.                                   SioRxBuf
  1682.  
  1683.  
  1684.  
  1685.          Function    Sets up receive buffers.
  1686.  
  1687.            Syntax    function SioRxBuf(Port,BufferOfs,BufferSeg,
  1688.                                          SizeCode:Integer) : Integer;
  1689.  
  1690.           Remarks    The SioRxBuf function passes the address and  size  of
  1691.                      the   receive  buffer  to  PCL4P.  Recall  that  PCL4P
  1692.                      requires  a  receive   buffer   for   each   port   in
  1693.                      simultaneous  operation  since the receive function is
  1694.                      interrupt driven. SioRxBuf passes the  receive  buffer
  1695.                      to  PCL4P  for  both  the  primary  (  COM1/COM3 ) and
  1696.                      secondary ( COM2/COM4 )  ports.   It  must  be  called
  1697.                      before   any  incoming  characters  can  be  received.
  1698.                      SioRxBuf must be called before SioReset.  Buffer  size
  1699.                      codes are listed in "PCL4P.H".
  1700.  
  1701.                      Size Code       Buffer Size    PCL4P.H Name
  1702.                         0              8 bytes        Size8
  1703.                         1             16 bytes        Size16
  1704.                         2             32 bytes        Size32
  1705.                         3             64 bytes        Size64
  1706.                         4            128 bytes        Size128
  1707.                         5            256 bytes        Size256
  1708.                         6            512 bytes        Size512
  1709.                         7           1024 bytes        Size1024 or Size1K
  1710.                         8           2048 bytes        Size2048 or Size2K
  1711.                         9           4096 bytes        Size4096 or Size4K
  1712.                        10           8192 bytes        Size8192 or Size8K
  1713.                        11          16384 bytes        Size16384 or Size16K
  1714.                        12          32768 bytes        Size32768 or Size32K
  1715.  
  1716.           Returns    -4 : Port out of range. Expecting 0 to 3.
  1717.                     -10 : Bad buffer size code. Expecting 0 to 11.
  1718.  
  1719.           Example
  1720.                      (* set up the receive buffer *)
  1721.                      RetCode := SioRxBuf( COM1, Ofs(RxBuf),Seg(RxBuf), 128);
  1722.  
  1723.          See Also    SioReset.
  1724.  
  1725.  
  1726.  
  1727.  
  1728.  
  1729.  
  1730.  
  1731.  
  1732.  
  1733.  
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
  1740.         PCL4P Reference Manual                                 Page 29
  1741.                                   SioRxFlush
  1742.  
  1743.  
  1744.  
  1745.          Function     To  flush  the  receive  buffer  associated  with the
  1746.                      specified port.
  1747.  
  1748.            Syntax    function SioRxFlush(Port:Integer) : Integer;
  1749.  
  1750.           Remarks    The SioRxFlush function will delete any characters  in
  1751.                      the  receive  buffer  for  the  specified port.  After
  1752.                      execution, the receive buffer  will  be  empty.   Call
  1753.                      SioRxBuf after resetting a port in order to delete any
  1754.                      spurious characters.
  1755.  
  1756.           Returns    -2 : Port not enabled. Call SioReset first.
  1757.                      -4 : Port out of range. Expecting 0 to 3.
  1758.  
  1759.           Example
  1760.  
  1761.                      (* setup receive buffer  and  reset port *)
  1762.                      RetCode := SioRxBuf(COM1,Ofs(Buffer),Seg(Buffer),Size1024);
  1763.                      RetCode := SioReset(COM1,Baud115200);
  1764.                      (* flush any spurious character *)
  1765.                      RetCode := SioRxFlush(COM1);
  1766.                      (* ready for serial processing ! *)
  1767.  
  1768.          See Also    SioRxQue.
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.  
  1788.  
  1789.  
  1790.  
  1791.  
  1792.  
  1793.  
  1794.  
  1795.  
  1796.  
  1797.  
  1798.  
  1799.  
  1800.         PCL4P Reference Manual                                 Page 30
  1801.                                   SioRxQue
  1802.  
  1803.  
  1804.  
  1805.          Function    Returns the number of characters in the receive queue.
  1806.  
  1807.            Syntax    function SioRxQue(Port:Integer) : Integer;
  1808.  
  1809.           Remarks    The  SioRxQue  function  will  return  the  number  of
  1810.                      characters in the receive queue. It  can  be  used  to
  1811.                      implement XON/XOFF flow control.
  1812.  
  1813.           Returns    -2 : Port not enabled. Call SioReset first.
  1814.                      -4 : Port out of range. Expecting  0 to 3.
  1815.  
  1816.           Example
  1817.  
  1818.                      RetCode := SioRxBuf(COM1,Ofs(Buffer),Seg(Buffer),Size128);
  1819.                      (* implement XON / XOFF *)
  1820.                      count := SioRxQue(COM1);
  1821.                      if (last=XON) and (count>120) then
  1822.                        begin
  1823.                          RetCode := SioPutc(COM1,char(XOFF));
  1824.                          last := XOFF;
  1825.                        end
  1826.                     if (last=XOFF) and (count<8) then
  1827.                       begin
  1828.                         RetCode := SioPutc(COM1,char(XON));
  1829.                         last := XON;
  1830.                       end
  1831.  
  1832.         See Also     SioRxFlush.
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854.  
  1855.  
  1856.  
  1857.  
  1858.  
  1859.  
  1860.         PCL4P Reference Manual                                 Page 31
  1861.                                   SioTimer
  1862.  
  1863.  
  1864.  
  1865.          Function    Returns  the  number  of  system  clock  tics   since
  1866.                      midnight.
  1867.  
  1868.            Syntax    function SioTimer : LongInt;
  1869.  
  1870.           Remarks    The SioTimer function will return the number of system
  1871.                      clock tics since midnight, at 18.2065 tics per second.
  1872.                      This function is usefull for timing various functions.
  1873.                      Also see SioDelay.
  1874.  
  1875.           Returns    timer tics.
  1876.  
  1877.           Example
  1878.  
  1879.                      Var Time : LongInt;
  1880.                      ...
  1881.                      Time := SioTimer();
  1882.                      (* do some stuff *)
  1883.                      Writeln('Elasped time ', SioTimer - Time );
  1884.  
  1885.          See Also    SioDelay.
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.         PCL4P Reference Manual                                 Page 32
  1921.                                   SioTxBuf
  1922.  
  1923.  
  1924.  
  1925.          Function    Sets up transmitter buffer.
  1926.  
  1927.            Syntax    function SioTxBuf(Port,BufferOfs,BufferSeg,
  1928.                                          SizeCode:Integer) : Integer;
  1929.  
  1930.           Remarks     The  SioTxBuf function passes the address and size of
  1931.                      the  transmit  buffer to PCL4P, provided that you will
  1932.                      link with a PCL4P library with transmitter  interrupts
  1933.                      enabled.   PCL4P  requires  a transmit buffer for each
  1934.                      port in simultaneous operation if you  are  using  the
  1935.                      version  of  the  library  with transmitter interrupts
  1936.                      enabled  (PCL4C_2.LIB).   SioTxBuf  must   be   called
  1937.                      before  SioReset.   Buffer  size  codes  are listed in
  1938.                      "PCL4C.H".
  1939.  
  1940.                      Size Code       Buffer Size    PCL4C.H Name
  1941.                         0              8 bytes        Size8
  1942.                         1             16 bytes        Size16
  1943.                         2             32 bytes        Size32
  1944.                         3             64 bytes        Size64
  1945.                         4            128 bytes        Size128
  1946.                         5            256 bytes        Size256
  1947.                         6            512 bytes        Size512
  1948.                         7           1024 bytes        Size1024 or Size1K
  1949.                         8           2048 bytes        Size2048 or Size2K
  1950.                         9           4096 bytes        Size4096 or Size4K
  1951.                        10           8192 bytes        Size8192 or Size8K
  1952.                        11          16384 bytes        Size16384 or Size16K
  1953.                        12          32768 bytes        Size32768 or Size32K
  1954.  
  1955.                      This function  is  not  used  unless  the  transmitter
  1956.                      interrupts  are  enabled  (PCL4C_2.LIB).  Refer to the
  1957.                      PCL4C Users Manual for information on transmitter (TX)
  1958.                      interrupts.
  1959.  
  1960.           Returns    -4 : No such port. Expect 0 to MaxPort.
  1961.                     -10 : Bad buffer size code. Expecting 0 to 11.
  1962.  
  1963.           Example    (* set up the transmit buffer *)
  1964.                      RetCode := SioRxBuf(COM1,Ofs(RxBuf),Seg(RxBuf),128);
  1965.  
  1966.  
  1967.          See Also    SioRxBuf and SioReset.
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.         PCL4P Reference Manual                                 Page 33
  1981.                                   SioTxFlush
  1982.  
  1983.  
  1984.  
  1985.          Function    To  flush  the  transmit  buffer  associated  with  the
  1986.                      specified port.
  1987.  
  1988.            Syntax    function SioTxFlush(Port : Integer) : Integer;
  1989.  
  1990.           Remarks    The SioTxFlush function will delete any characters  in
  1991.                      the transmit buffer for the specified  port,  provided
  1992.                      that  you  will  link  with  the  PCL4P  library  with
  1993.                      transmitter interrupts enabled.  After execution,  the
  1994.                      transmit buffer will be empty.
  1995.  
  1996.                      Once  this  function  is  called, any character in the
  1997.                      transmit buffer (put there by SioPutc)  will  be  lost
  1998.                      and therefore not transmitted.
  1999.  
  2000.                      This function  is  not  used  unless  the  transmitter
  2001.                      interrupts  are  enabled  (PCL4C_2.LIB).  Refer to the
  2002.                      PCL4C Users Manual for information on transmitter (TX)
  2003.                      interrupts.
  2004.  
  2005.           Returns    -2 : Port not enabled. Call SioReset first.
  2006.                      -4 : No such port. Expect 0 to MaxPort.
  2007.  
  2008.           Example    char buffer[1024];
  2009.                      ...
  2010.                      /* setup transmit buffer & reset port */
  2011.                      SioTxBuf(COM1,buffer,Size1024);
  2012.                      SioReset(COM1,Baud115200);
  2013.                      /* flush any spurious character */
  2014.                      SioTxFlush(COM1);
  2015.                      /* ready for serial processing ! */
  2016.                      ...
  2017.  
  2018.          See Also    SioTxQue.
  2019.  
  2020.  
  2021.  
  2022.  
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.         PCL4P Reference Manual                                 Page 34
  2041.                                   SioTxQue
  2042.  
  2043.  
  2044.  
  2045.          Function    Returns the number of characters in the transmit queue.
  2046.  
  2047.            Syntax    int SioTxQue(Port)
  2048.                      int Port;     /* Port selected (COM1 thru COM4) */
  2049.  
  2050.           Remarks    The  SioTxQue  function  will  return  the  number  of
  2051.                      characters  in  the  transmit queue at the time of the
  2052.                      call, provided that you will link with a PCL4C library
  2053.                      with transmitter interrupts enabled.
  2054.  
  2055.                      This function  is  not  used  unless  the  transmitter
  2056.                      interrupts  are  enabled  (PCL4C_2.LIB).  Refer to the
  2057.                      PCL4C Users Manual for information on transmitter (TX)
  2058.                      interrupts.
  2059.  
  2060.           Returns    -2 : Port not enabled. Call SioReset first.
  2061.                      -4 : No such port. Expect 0 to MaxPort.
  2062.  
  2063.  
  2064.           Example    ...
  2065.                      RetCode := SioTxBuf(COM1,Ofs(Buffer),Seg(Buffer),Size128);
  2066.                      (* display # bytes in TX queue *)
  2067.                      Count := SioTxQue(COM1);
  2068.                      ...
  2069.  
  2070.         See Also     SioTxFlush.
  2071.  
  2072.  
  2073.  
  2074.  
  2075.  
  2076.  
  2077.  
  2078.  
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.         PCL4P Reference Manual                                 Page 35
  2101.                                   SioTimer
  2102.  
  2103.  
  2104.  
  2105.          Function    Returns  the  number  of  system  clock  tics   since
  2106.                      midnight.
  2107.  
  2108.            Syntax    function SioTimer : LongInt;
  2109.  
  2110.           Remarks    The SioTimer function will return the number of system
  2111.                      clock tics since midnight, at 18.2065 tics per second.
  2112.                      This function is usefull for timing various functions.
  2113.                      Also see SioDelay.
  2114.  
  2115.           Returns    timer tics.
  2116.  
  2117.           Example
  2118.  
  2119.                      Var Time : LongInt;
  2120.                      ...
  2121.                      Time := SioTimer();
  2122.                      (* do some stuff *)
  2123.                      Writeln('Elasped time ', SioTimer - Time );
  2124.  
  2125.          See Also    SioDelay.
  2126.  
  2127.  
  2128.  
  2129.  
  2130.  
  2131.  
  2132.  
  2133.  
  2134.  
  2135.  
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  
  2145.  
  2146.  
  2147.  
  2148.  
  2149.  
  2150.  
  2151.  
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.         PCL4P Reference Manual                                 Page 36
  2161.                                   SioUART
  2162.  
  2163.  
  2164.  
  2165.          Function    Sets the UART base address.
  2166.  
  2167.            Syntax    function SioUART(Port,Address:Integer) : Integer;
  2168.  
  2169.           Remarks    The SioUART function sets the UART  base  address  for
  2170.                      the  specified  port.   SioUART  must be called before
  2171.                      SioReset in order to have effect.  Be  extremely  sure
  2172.                      that you know what you are doing! Note that PCL4P uses
  2173.                      the   standard   PC/XT/AT  port  addresses,  interrupt
  2174.                      request  lines,   and   interrupt   service   vectors.
  2175.                      Therefore,   this   function   is   only   needed  for
  2176.                      non-standard ports.
  2177.  
  2178.           Returns     >0 : The previous base address for this port.
  2179.                      -4  : Port out of range.  Expecting 0 to 3.
  2180.                      -15 : Port already enabled. SioReset already called.
  2181.  
  2182.  
  2183.           Example    (* Record fact that you don't have COM4 *)
  2184.                      RetCode := SioUART(COM4, 0);
  2185.  
  2186.          See Also    SioReset, SioIRQ.
  2187.  
  2188.  
  2189.  
  2190.  
  2191.  
  2192.  
  2193.  
  2194.  
  2195.  
  2196.  
  2197.  
  2198.  
  2199.  
  2200.  
  2201.  
  2202.  
  2203.  
  2204.  
  2205.  
  2206.  
  2207.  
  2208.  
  2209.  
  2210.  
  2211.  
  2212.  
  2213.  
  2214.  
  2215.  
  2216.  
  2217.  
  2218.  
  2219.  
  2220.         PCL4P Reference Manual                                 Page 37
  2221.                                   SioUnGetc
  2222.  
  2223.  
  2224.  
  2225.          Function    "Un-gets" the last character read with SioGetc().
  2226.  
  2227.            Syntax    function SioUnGetc(Port:Integer; Ch:Char) : Integer;
  2228.  
  2229.           Remarks    The  SioUnGetc  function  returns  (  pushes  )   the
  2230.                      character  back  into  the  serial  input buffer.  The
  2231.                      character pushed will be the next  character  returned
  2232.                      by  SioGetc.  Only  one  character can be pushed back.
  2233.                      This function works just like the "ungetc" function in
  2234.                      the C language.
  2235.  
  2236.           Returns    -2 : Port not enabled. Call SioReset first.
  2237.                      -4 : Port out of range. Expecting 0 to 3.
  2238.  
  2239.           Example    (* push back c so next SioGetc will get it *)
  2240.                      RetCode := SioUnGetc(Port,c);
  2241.  
  2242.          See Also    SioReset.
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.  
  2249.  
  2250.  
  2251.  
  2252.  
  2253.  
  2254.  
  2255.  
  2256.  
  2257.  
  2258.  
  2259.  
  2260.  
  2261.  
  2262.  
  2263.  
  2264.  
  2265.  
  2266.  
  2267.  
  2268.  
  2269.  
  2270.  
  2271.  
  2272.  
  2273.  
  2274.  
  2275.  
  2276.  
  2277.  
  2278.  
  2279.  
  2280.         PCL4P Reference Manual                                 Page 38
  2281.                                   Function Sumary
  2282.  
  2283.  
  2284.  
  2285.          ***********************************************************
  2286.          * Function    *   Arg1   *   Arg2   *   Arg3   *   Arg4   *
  2287.          ***********************************************************
  2288.          * SioBaud     * Port     * BaudCode *          *          *
  2289.          * SioBrkKey   *          *          *          *          *
  2290.          * SioBrkSig   * Port     * Cmd      *          *          *
  2291.          * SioCTS      * Port     *          *          *          *
  2292.          * SioDCD      * Port     *          *          *          *
  2293.          * SioDelay    * Tics     *          *          *          *
  2294.          * SioDone     * Port     *          *          *          *
  2295.          * SioDSR      * Port     *          *          *          *
  2296.          * SioDTR      * Port     * Cmd      *          *          *
  2297.          * SioError    * Code     *          *          *          *
  2298.          * SioFIFO     * Port     * FIFOcode *          *          *
  2299.          * SioFlow     * Port     * Tics     *          *          *
  2300.          * SioGetc     * Port     * Tics     *          *          *
  2301.          * SioInfo     * Cmd      *          *          *          *
  2302.          * SioIRQ      * Port     * IRQcode  * ISRcode  *          *
  2303.          * SioLine     * Port     *          *          *          *
  2304.          * SioLoopBack * Port     *          *          *          *
  2305.          * SioModem    * Port     * Mask     *          *          *
  2306.          * SioParms    * Port     * Parity   * StopBits *WordLength*
  2307.          * SioPorts    * Ports    * FirstDB  * StatusReg*          *
  2308.          * SioPutc     * Port     * Ch       *          *          *
  2309.          * SioRead     * Port     * Register *          *          *
  2310.          * SioReset    * Port     * BaudCode *          *          *
  2311.          * SioRI       * Port     *          *          *          *
  2312.          * SioRTS      * Port     * Cmd      *          *          *
  2313.          * SioRxBuf    * Port     * Ofs(Buff)* Seg(Buff)* SizeCode *
  2314.          * SioRxFlush  * Port     *          *          *          *
  2315.          * SioRxQue    * Port     *          *          *          *
  2316.          * SioTimer    *          *          *          *          *
  2317.          * SioTxBuf    * Port     * Ofs(Buff)* Seg(Buff)* SizeCode *
  2318.          * SioTxFlush  * Port     *          *          *          *
  2319.          * SioTxQue    * Port     *          *          *          *
  2320.          * SioUART     * Port     * Address  *          *          *
  2321.          * SioUnGetc   * Port     * Ch       *          *          *
  2322.          ***********************************************************
  2323.  
  2324.          ( 34 functions)
  2325.  
  2326.  
  2327.  
  2328.  
  2329.  
  2330.  
  2331.  
  2332.  
  2333.  
  2334.  
  2335.  
  2336.  
  2337.  
  2338.  
  2339.  
  2340.         PCL4P Reference Manual                                 Page 39
  2341.                     Error Code Summary
  2342.  
  2343.  
  2344.  
  2345.          *****************************************************************
  2346.          * Code *  Description                                           *
  2347.          *****************************************************************
  2348.          *   0  *  No error.                                             *
  2349.          *  -1  *  Timeout waiting for input. (Only returned by SioGetc).*
  2350.          *  -2  *  Port not enabled. Call SioReset first.                *
  2351.          *  -3  *  No buffer available.  Call SioRxBuf first.            *
  2352.          *  -4  *  Port out of range. Expecting 0 to 3. (COM1 = 0)       *
  2353.          *  -5  *  Expected 'S', 'C', or 'R' as second argument.         *
  2354.          *  -6  *  Expected 'A', 'C', or 'D' as second argument.         *
  2355.          *  -7  *  Bad parity code specified. Must be 0 to 7.            *
  2356.          *  -8  *  Bad stop bits code specified. Must be 0 or 1.         *
  2357.          *  -9  *  Bad wordlength code specified. Must be 0 to 3.        *
  2358.          * -10  *  Bad buffer size code specified. Must be 0 to 11.      *
  2359.          * -11  *  Bad baud rate code. Must be 0 to 9.                   *
  2360.          * -12  *  Loopback test fails.                                  *
  2361.          * -13  *  UART undefined.                                       *
  2362.          * -14  *  Missing or bad UART.                                  *
  2363.          * -15  *  Port already enabled.                                 *
  2364.          * -16  *  Interrupt already in use.                             *
  2365.          * -17  *  No such IRQ. (Should be 2 to 7)                       *
  2366.          * -18  *  ISR limit exceeded.                                   *
  2367.          *****************************************************************
  2368.  
  2369.  
  2370.  
  2371.  
  2372.  
  2373.  
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.  
  2381.  
  2382.  
  2383.  
  2384.  
  2385.  
  2386.  
  2387.  
  2388.  
  2389.  
  2390.  
  2391.  
  2392.  
  2393.  
  2394.  
  2395.  
  2396.  
  2397.  
  2398.  
  2399.  
  2400.         PCL4P Reference Manual                                 Page 40
  2401.